<?php
class Controller_Test_Payment extends Controller
{
    public function __construct ($request, $response)
    {
        parent::__construct($request, $response);
    }

    public function action_weixin ()
    {
        $orderNo = '20151203001';
        $money   = 3;
        $title   = "订单测试001";


        $pay = new Pay_Pay(array(
            'body'         => $title,
            'out_trade_no' => $orderNo,
            'total_fee'    => $money,
        ));

        $imgsrc = $pay->create_pay_order();

        echo "<img src=\"$imgsrc\">";
    }

    public function action_alipay ()
    {
        $orderNo = '20151203001';
        $money   = 3;   // 分
        $title   = "订单测试001";

        $pay = Paysdk::instance("alipay");
        $parameter = array(
            "out_trade_no" => $orderNo,
            "total_fee"    => $money / 100,
            "body"         => $title, 
        );

        $form = $pay->set_info($parameter)->get_form("继续支付");
        $content =<<<EOF
$form
<script>
var form = document.forms[0];
if (form)
    form.submit();
</script>
EOF;
        echo $content;exit;
        $this->template->set_filename('smarty:chong/creat_order');
        $this->template->set('form',$form);
    }

}
